package com.hk.jdk21;

/**
 * Switch 语法增强，可以在case 后加类型
 *
 * @author Kevin
 * @date 2023-10-21 11:26
 */
public class SwitchTest {

    public static void main(String[] args) {
        Object o = "string";
        if (args.length > 5) {
            o = 1;
        } else if (args.length == 1) {
            o = 1.0;
        }
        switch (o) {
            case Integer v -> System.out.printf("o is int:%d", v);
            case String str -> System.out.printf("o is string:%s", str);
            case Double d -> System.out.printf("o is double:%s", d);
            default -> throw new IllegalStateException("Unexpected value: " + o);
        }
    }
}
